package com.example.slidingui;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MenuFragment extends ListFragment {
	static final String[] MENU = { "Menu1", "Menu2", "Menu3", "Menu4", "Menu5", "Menu6", "Menu1", "Menu2", "Menu3", "Menu4", "Menu5", "Menu6", "Menu1", "Menu2", "Menu3", "Menu4", "Menu5", "Menu6", };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, MENU));
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		final int action = position;

		Bundle args = new Bundle();
		args.putInt("action", action);

		// attach content
		ContentFragment f = new ContentFragment();
		f.setArguments(args);

		// open menu
		Activity a = getActivity();
		if (a instanceof MainActivity) {
			((MainActivity) a).addFragmentWithStack(f, null);
		}
	}
}
